Skip to content

fix: pdfjs cjs esm interop#37

Merged
vitormattos merged 2 commits intomainfrom
fix/pdfjs-cjs-esm-interop
Mar 1, 2026
Merged

fix: pdfjs cjs esm interop#37
vitormattos merged 2 commits intomainfrom
fix/pdfjs-cjs-esm-interop

Conversation

@vitormattos
Copy link
Member

No description provided.

In Vite watch mode, pdfjs-dist is served without pre-bundling when the
package is linked via file: path, causing the module to be wrapped under
.default instead of exposing named exports directly. This results in
PDFWorker being undefined at runtime.

- Add normalizePdfjs() to unwrap .default when present (CJS/ESM interop)
- Guard ensureWorkerSrc against undefined GlobalWorkerOptions
- Reset sharedWorker to null in setWorkerPath to force recreation
- Add .catch with console.warn in setWorkerPath for failed async updates

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos self-assigned this Mar 1, 2026
@vitormattos vitormattos merged commit 1f867a6 into main Mar 1, 2026
4 checks passed
@vitormattos vitormattos deleted the fix/pdfjs-cjs-esm-interop branch March 1, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant